/*
    This file is part of Slydini.

    Slydini is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Slydini is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Slydini.  If not, see <http://www.gnu.org/licenses/>.
*/
/* 
 * File:   ellipse.h
 * Author: kajetan
 *
 * Created on 28 marzec 2009, 13:58
 */

#ifndef _ELLIPSE_H
#define	_ELLIPSE_H

#include "libs.h"

struct MyEllipse {
	CvPoint center;
	CvSize size;
	double angle;

	MyEllipse() {
	}

	MyEllipse(const MyEllipse& p) {
		center.x = p.center.x;
		center.y = p.center.y;
		size = p.size;
		angle = p.angle;
	}

	MyEllipse& operator=(const MyEllipse& p) {
		center.x = p.center.x;
		center.y = p.center.y;
		size = p.size;
		angle = p.angle;
		return *this;
	}

	MyEllipse(CvPoint c, CvSize s, double a = 0.) : center(c), size(s), angle(a) {}

	bool operator==(const MyEllipse& p) {
		return ((p.center.x-center.x)*(p.center.x-center.x)+
				(p.center.y-center.y)*(p.center.y-center.y) <= 2*((p.size.width+size.width)+(p.size.height+size.height))*
				((p.size.width+size.width)+(p.size.height+size.height)));
	}

	static int dstSq(const MyEllipse& a, const MyEllipse& b) {
		return ((a.center.x-b.center.x)*(a.center.x-b.center.x)+(a.center.y-b.center.y)*(a.center.y-b.center.y));
	}
};

#endif	/* _ELLIPSE_H */


